﻿<%@ WebHandler Language="C#" Class="detail" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using Newtonsoft.Json.Linq;
using System.Collections;

public class detail : IHttpHandler {

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        var _hid = HttpContext.Current.Request.Params["rid"];

        int hid = Convert.ToInt16(_hid);

        if (string.IsNullOrEmpty(_hid))
        {
            HttpContext.Current.Response.Write("parameter error");
            return;
        }

        var code = 1;
        var msg = "商品详情";
        var time = DateTime.Now;

        using (Entities bll = new Entities())
        {

            var x = bll.S_Room.FirstOrDefault(p => p.RID == hid);

            if (x != null)
            {
                var GetImgs = methods.GetImgs(x.RImg);


                var data = new
                {

                    x,
                    img = GetImgs
                };

                context.Response.Write(JsonConvert.SerializeObject(new { code, msg, time, data }));

            }

            HttpContext.Current.Response.End();
            //context.Response.Write("Hello World");

        }
    }





    public bool IsReusable {
        get {
            return false;
        }
    }

}